/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package org.teama;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.ResultSet;
import static java.util.logging.Level.INFO;

/**
 *
 * @author bamidei
 */
public class UserDA {

    static public int getDefaultSortPref()
    {
        return 1;
    }
    
    static public boolean insert(User us) {
       boolean retVal;

        try {
            ResultSet rs;
            Connection conn = DBconnect.getConnection();
            Statement statement = conn.createStatement();
            String text = "INSERT INTO BugTracker.Users " +
                              "(lastName, firstName, emailAddress, sortPreference)" +
                              " VALUES ('" + 
                              us.getLastName() + "', '" + us.getFirstName() + "', '" + 
                              us.getEmailAddress() + "', " + us.getSortPreference() + ");";
            statement.execute (text);
            statement.close();
            conn.close();
            retVal = true;
        } catch (SQLException e) {
            DBconnect.getLogger().log(INFO, "Database Error inserting user info.", e);
            retVal=false;
        }       
       return retVal;    
    }
}